package com.yonyou.crm.sprc.oppflow.rmimpl;

import com.yonyou.crm.common.page.entity.Page;
import com.yonyou.crm.sprc.oppflow.entity.OppflowVO;
import com.yonyou.crm.sprc.oppflow.rmitf.IOppflowRmService;
import com.yonyou.crm.sprc.oppflow.service.OppflowBizServiceImpl;
import com.yonyou.crm.sys.modules.entity.MtObjTypeEnum;
import com.yonyou.crm.sys.modules.service.BiztypeBizServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("oppflowService")
public class OppflowRmServiceImpl implements IOppflowRmService {

	@Autowired
	private OppflowBizServiceImpl service;
	@Autowired
	private BiztypeBizServiceImpl biztypeService;

	@Override
	public Page<OppflowVO> getList(Page<OppflowVO> requestPage, Map<String, Object> searchMap) {
		return service.getList(requestPage, searchMap);
	}

	@Override
	public OppflowVO detail(String id) {
		// TODO 自动生成的方法存根
		return null;
	}

	@Override
	public OppflowVO insert(OppflowVO vo, List<Map<String, Object>> flowStageList, List<Map<String, Object>> stageActionList) {
		OppflowVO oppflowVO = service.saveVO(vo, flowStageList , stageActionList);
		return oppflowVO;
	}

	@Override
	public OppflowVO update(OppflowVO vo, List<Map<String, Object>> flowStageList, List<Map<String, Object>> stageActionList) {
		OppflowVO oppflowVO = service.updateVO(vo, flowStageList , stageActionList);
		oppflowVO = service.getOppflowVOById(oppflowVO.getId());
		return oppflowVO;
	}

	@Override
	public int delete(String id) {
		return service.deleteByID(id);
	}

	@Override
	public Map<String, Object> getDetail(Long id) {
		Map<String, Object> returnMap = service.getDetail(id);
		return returnMap;
	}

	@Override
	public List<OppflowVO> getList(Map<String, Object> searchMap) {
		return service.getList(searchMap);
	}

	@Override
	public Map<String, Object> getBizType() {
		return biztypeService.getModuleBiztypesForCurrentRole(new Long(MtObjTypeEnum.OPPORTUNITY.getValue()+""));
	}

	@Override
	public List<OppflowVO> batchUpdateEnableState(String[] idArray, Integer enableState,Map<String, Object> searchMap) {
		service.batchUpdateEnableState(idArray, enableState);
		return service.getList(searchMap);
	}

	@Override
	public int checkBiztypeRepeat(String biztype){
		return service.checkBiztypeRepeat(biztype);
	}

}
